<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        body {
            background-color: #bbb;
        }

        #canvas {
            background-color: #fff;
        }
    </style>
</head>

<body>
    <canvas id="canvas" width="400" height="400"></canvas>
</body>
<script src="./utils.js"></script>
<script>
    window.onload = () => {
        var canvas = document.getElementById("canvas")
        var context = canvas.getContext('2d')
        var points = []
        var numPoints = 9
        var cirlPoints = {}

        for (let i = 0; i < numPoints; i++) {
            points.push({
                x: Math.random() * canvas.width,
                y: Math.random() * canvas.height,
            })
        }

        context.beginPath()
        context.moveTo(points[0].x, points[0].y)

        for (i = 1; i < numPoints - 2; i++) {
            cirlPoints.x = (points[i].x + points[i + 1].x) / 2
            cirlPoints.y = (points[i].y + points[i + 1].y) / 2
            context.quadraticCurveTo(points[i].x, points[i].y, cirlPoints.x, cirlPoints.y)
        }

        context.quadraticCurveTo(points[i].x, points[i].y, points[i + 1].x, points[i + 1].y)
        context.stroke()
    }
</script>

</html>